﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VBAConvertor
{
    public class LinesReader
    {
        private readonly List<string> _Lines;

        public int CurrentLine { get; set; }

        public bool End { get { return CurrentLine >= _Lines.Count; } }

        public LinesReader(Stream source)
        {
            _Lines = new List<string>();
            using (var sr = new StreamReader(source, Encoding.UTF8, true, 2048, true))
            {
                while (!sr.EndOfStream)
                {
                    _Lines.Add(sr.ReadLine());
                }
            }
            CurrentLine = 0;
        }

        public string ReadLine()
        {
            string line = null;
            if (!End)
            {
                line = _Lines[CurrentLine];
                CurrentLine++;
            }
            return line;
        }
    }
}
